//
//  JCMomentMessageCell.m
//  Victor
//
//  Created by 郭吉成 on 2017/10/16.
//  Copyright © 2017年 coollang. All rights reserved.
//

#import "JCMomentMessageCell.h"
#import "JCMessageListModel.h"
#import "UIImageView+WebCache.h"

@interface JCMomentMessageCell ()
@property (weak, nonatomic) IBOutlet UIImageView *headerImage;
@property (weak, nonatomic) IBOutlet UILabel *nickNameLabel;
@property (weak, nonatomic) IBOutlet UIImageView *messageTypeImage;
@property (weak, nonatomic) IBOutlet UILabel *messageTypeLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *previewImage;
@property (weak, nonatomic) JCMessageListModel *messageModel;

@end

@implementation JCMomentMessageCell

- (void)setMessageModel:(JCMessageListModel *)model{
    _messageModel = model;
    [_headerImage sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:kUserHeadPlaceholdImage];
    _nickNameLabel.text = model.userName;
    _messageTypeImage.image = [UIImage imageNamed:model.messageType==MessageTypeLike?@"find_like_list":@"find_comment_action"];
    
    _messageTypeLabel.text = model.messageType==MessageTypeLike?NSLocalizedString(@"Likes your moments", nil):NSLocalizedString(@"Comments on your moments", nil);
    _timeLabel.text = model.creatTime;
    if (model.imageList.count > 0) {
        _previewImage.hidden = NO;
        [_previewImage sd_setImageWithURL:[NSURL URLWithString:model.imageList.firstObject] placeholderImage:kPlaceholdImage];
    }else{
        _previewImage.hidden = YES;
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    _headerImage.layer.cornerRadius = 20;
    _headerImage.layer.masksToBounds = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
